{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "99e98c69",
   "metadata": {},
   "source": [
    "# IIR双线性变换法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "463ae9ec",
   "metadata": {},
   "source": [
    "利用双线性变换法，把下列模拟域的模拟滤波器转换为数字滤波器，采样周期T=0.01。\n",
    "\n",
    "\tH(s)=(s+1)/(s^2+5s+6)\t \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "535aef7c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([ 4.90172170e-03,  4.87733502e-05, -4.85294835e-03]),\n",
       " array([ 1.        , -1.95064137,  0.95122665]))"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#library\n",
    "import numpy as np\n",
    "from scipy import signal\n",
    "\n",
    "#analog filter transfer function\n",
    "b_analog = np.array([1,1]) #numerator\n",
    "a_analog = np.array([1,5,6]) #denominator\n",
    "T = 0.01;fs = 1/T #sampling rate\n",
    "\n",
    "#bilinear transformation method\n",
    "filtz = signal.bilinear(b_analog,a_analog,fs)\n",
    "filtz"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a1477a7e",
   "metadata": {},
   "source": [
    "对应Z域的系统函数为\n",
    "\n",
    "\tH(z)=(0.00490172-0.00004877z^(-1)-0.00485295)/(1-1.95064137z^(-1)+0.95122265z^(-2) )\t\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
